
#pragma once


namespace __OCF_STUB__ 
{


using namespace __OCF_BASE__;

#define MAX_INPUT	(4096)


#define __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__

template <class IF>
class CFrontToMiddle
{
	typedef TYPE_LIST05(USHORT,char,char*,int,int*) _OCF_PROXYSTUB_TYPELIST_T;
	enum __ENUM_PROXYSTUB_FUNCTION_TYPE__
	{
		__ENUM_FUNCTION_TYPE_fnRequestToMiddleWithAsync__ = 1,
		__ENUM_FUNCTION_TYPE_fnRequestToMiddleWithSync__ = 2,
		__ENUM_FUNCTION_TYPE_fnRequestToMiddleWithAsyncEcho__ = 3,
		__ENUM_FUNCTION_TYPE_fnRequestToMiddleWithSyncEcho__ = 4,

		__END__
	};
	typedef IF _N_IF_T;
	typedef long (CFrontToMiddle<_N_IF_T>::*_FUNC_T)(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn);

public:
	CFrontToMiddle(_N_IF_T* pcIf)
		:m_pcIf(pcIf)
	{
		m_ulLenRcvBuff = 0;
		m_pRcvBuff = NULL;
		m_pCurrRcvBuff = NULL;
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
		m_ulLenSndBuff = 0;
		m_pSndBuff = NULL;
#endif
	}
	virtual ~CFrontToMiddle()
	{
	}
	CFrontToMiddle& operator =(const CFrontToMiddle& cFrom)
	{
		m_pcIf = cFrom.m_pcIf;
		m_ulLenRcvBuff = cFrom.m_ulLenRcvBuff;
		m_pRcvBuff = cFrom.m_pRcvBuff;
		m_pCurrRcvBuff = cFrom.m_pCurrRcvBuff;
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
		m_ulLenSndBuff = cFrom.m_ulLenSndBuff;
		m_pSndBuff = cFrom.m_pSndBuff;
#endif

		return *this;
	}
	long StubDispatch()
	{
		CIn<_OCF_PROXYSTUB_TYPELIST_T> cIn(m_ulLenRcvBuff, m_pRcvBuff);
		USHORT uiCmd;

		if (FALSE == cIn.Pop(uiCmd).IsValid())
		{
			return -3;
		}
		if (uiCmd >= __END__)
		{
			return -4;
		}
		if (NULL == m_apcFunc[uiCmd])
		{
			return -5;
		}

		long lRet = (this->*m_apcFunc[uiCmd])(cIn);
		if (0 <= lRet)
		{
			m_pCurrRcvBuff = cIn.GetCurrDataPtr();
		}

		return lRet; 
	}

public:
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
	inline void SetStubInfo(ULONG ulLenRcvBuff, const void* pRcvBuff, ULONG ulLenSndBuff = 0, void* pSndBuff = NULL) { m_ulLenRcvBuff = ulLenRcvBuff; m_pRcvBuff = pRcvBuff; m_pCurrRcvBuff = pRcvBuff; m_ulLenSndBuff = ulLenSndBuff; m_pSndBuff = pSndBuff; }

	inline void* GetCurrRcvBuff() { return m_pCurrRcvBuff; }
#else
	inline void SetStubInfo(ULONG ulLenRcvBuff, const void* pRcvBuff) { m_ulLenRcvBuff = ulLenRcvBuff; m_pRcvBuff = pRcvBuff; m_pCurrRcvBuff = pRcvBuff; }

	inline void* GetCurrRcvBuff() { return m_pCurrRcvBuff; }
#endif
private:
	long fnRequestToMiddleWithAsync(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn_A3C01056_FD2D_4800_912C_69683F47B599_)
	{
		int nAuthKey;
		if (FALSE == cIn_A3C01056_FD2D_4800_912C_69683F47B599_.Pop(nAuthKey).IsValid()) return -1;
		long _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_ = m_pcIf->fnRequestToMiddleWithAsync(nAuthKey);
		return _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_;
	}
	long fnRequestToMiddleWithSync(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn_A3C01056_FD2D_4800_912C_69683F47B599_)
	{
		int nAuthKey;int nLenReturn;char pszReturn[MAX_INPUT];
		if (FALSE == cIn_A3C01056_FD2D_4800_912C_69683F47B599_.Pop(nAuthKey).IsValid()) return -1;
		long _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_ = m_pcIf->fnRequestToMiddleWithSync(nAuthKey,nLenReturn,pszReturn);
		if (0 != _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_) return _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_;
		COut<_OCF_PROXYSTUB_TYPELIST_T> cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_(m_ulLenSndBuff, m_pSndBuff);
		if (FALSE == cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_.Push(static_cast<USHORT>(2)).Push(nLenReturn,pszReturn).IsValid()) return -2;
		return m_pcIf->SendResult(cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_.GetDataLength(), cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_.GetStartDataPtr());
	}
	long fnRequestToMiddleWithAsyncEcho(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn_A3C01056_FD2D_4800_912C_69683F47B599_)
	{
		ULONG nInLen;char * pszInString;
		if (FALSE == cIn_A3C01056_FD2D_4800_912C_69683F47B599_.Pop(nInLen,(const char ** )(&pszInString)).IsValid()) return -1;
		long _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_ = m_pcIf->fnRequestToMiddleWithAsyncEcho((int )nInLen,pszInString);
		return _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_;
	}
	long fnRequestToMiddleWithSyncEcho(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn_A3C01056_FD2D_4800_912C_69683F47B599_)
	{
		ULONG nInLen;char * pszInString;int nOutLen;char pszOutString[MAX_INPUT];
		if (FALSE == cIn_A3C01056_FD2D_4800_912C_69683F47B599_.Pop(nInLen,(const char ** )(&pszInString)).IsValid()) return -1;
		long _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_ = m_pcIf->fnRequestToMiddleWithSyncEcho((int )nInLen,pszInString,nOutLen,pszOutString);
		if (0 != _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_) return _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_;
		COut<_OCF_PROXYSTUB_TYPELIST_T> cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_(m_ulLenSndBuff, m_pSndBuff);
		if (FALSE == cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_.Push(static_cast<USHORT>(4)).Push(nOutLen,pszOutString).IsValid()) return -2;
		return m_pcIf->SendResult(cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_.GetDataLength(), cTmpOut_19DB7D7A_2FBD_49c7_873C_9603A9FC0050_.GetStartDataPtr());
	}

private:
	static _FUNC_T m_apcFunc[__END__];
	_N_IF_T* m_pcIf;
	ULONG m_ulLenRcvBuff;
	const void* m_pRcvBuff;
	const void* m_pCurrRcvBuff;
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
	ULONG m_ulLenSndBuff;
	void* m_pSndBuff;
#endif
};

template <class IF>
typename CFrontToMiddle<IF>::_FUNC_T CFrontToMiddle<IF>::m_apcFunc[__END__] = {
	NULL,
	&CFrontToMiddle<IF>::fnRequestToMiddleWithAsync,
	&CFrontToMiddle<IF>::fnRequestToMiddleWithSync,
	&CFrontToMiddle<IF>::fnRequestToMiddleWithAsyncEcho,
	&CFrontToMiddle<IF>::fnRequestToMiddleWithSyncEcho,
};


#undef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__


template <class IF>
class CMiddleToFront
{
	typedef TYPE_LIST05(USHORT,char,char*,int,int*) _OCF_PROXYSTUB_TYPELIST_T;
	enum __ENUM_PROXYSTUB_FUNCTION_TYPE__
	{
		__ENUM_FUNCTION_TYPE_fnReturnWithAsync__ = 101,
		__ENUM_FUNCTION_TYPE_fnReturnWithAsyncEcho__ = 102,

		__END__
	};
	typedef IF _N_IF_T;
	typedef long (CMiddleToFront<_N_IF_T>::*_FUNC_T)(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn);

public:
	CMiddleToFront(_N_IF_T* pcIf)
		:m_pcIf(pcIf)
	{
		m_ulLenRcvBuff = 0;
		m_pRcvBuff = NULL;
		m_pCurrRcvBuff = NULL;
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
		m_ulLenSndBuff = 0;
		m_pSndBuff = NULL;
#endif
	}
	virtual ~CMiddleToFront()
	{
	}
	CMiddleToFront& operator =(const CMiddleToFront& cFrom)
	{
		m_pcIf = cFrom.m_pcIf;
		m_ulLenRcvBuff = cFrom.m_ulLenRcvBuff;
		m_pRcvBuff = cFrom.m_pRcvBuff;
		m_pCurrRcvBuff = cFrom.m_pCurrRcvBuff;
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
		m_ulLenSndBuff = cFrom.m_ulLenSndBuff;
		m_pSndBuff = cFrom.m_pSndBuff;
#endif

		return *this;
	}
	long StubDispatch()
	{
		CIn<_OCF_PROXYSTUB_TYPELIST_T> cIn(m_ulLenRcvBuff, m_pRcvBuff);
		USHORT uiCmd;

		if (FALSE == cIn.Pop(uiCmd).IsValid())
		{
			return -3;
		}
		if (uiCmd >= __END__)
		{
			return -4;
		}
		if (NULL == m_apcFunc[uiCmd])
		{
			return -5;
		}

		long lRet = (this->*m_apcFunc[uiCmd])(cIn);
		if (0 <= lRet)
		{
			m_pCurrRcvBuff = cIn.GetCurrDataPtr();
		}

		return lRet; 
	}

public:
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
	inline void SetStubInfo(ULONG ulLenRcvBuff, const void* pRcvBuff, ULONG ulLenSndBuff = 0, void* pSndBuff = NULL) { m_ulLenRcvBuff = ulLenRcvBuff; m_pRcvBuff = pRcvBuff; m_pCurrRcvBuff = pRcvBuff; m_ulLenSndBuff = ulLenSndBuff; m_pSndBuff = pSndBuff; }

	inline void* GetCurrRcvBuff() { return m_pCurrRcvBuff; }
#else
	inline void SetStubInfo(ULONG ulLenRcvBuff, const void* pRcvBuff) { m_ulLenRcvBuff = ulLenRcvBuff; m_pRcvBuff = pRcvBuff; m_pCurrRcvBuff = pRcvBuff; }

	inline void* GetCurrRcvBuff() { return m_pCurrRcvBuff; }
#endif
private:
	long fnReturnWithAsync(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn_A3C01056_FD2D_4800_912C_69683F47B599_)
	{
		ULONG nLenReturn;char * pszReturn;
		if (FALSE == cIn_A3C01056_FD2D_4800_912C_69683F47B599_.Pop(nLenReturn,(const char ** )(&pszReturn)).IsValid()) return -1;
		long _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_ = m_pcIf->fnReturnWithAsync((int )nLenReturn,pszReturn);
		return _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_;
	}
	long fnReturnWithAsyncEcho(CIn<_OCF_PROXYSTUB_TYPELIST_T>& cIn_A3C01056_FD2D_4800_912C_69683F47B599_)
	{
		ULONG nOutLen;char * pszOutString;
		if (FALSE == cIn_A3C01056_FD2D_4800_912C_69683F47B599_.Pop(nOutLen,(const char ** )(&pszOutString)).IsValid()) return -1;
		long _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_ = m_pcIf->fnReturnWithAsyncEcho((int )nOutLen,pszOutString);
		return _lRet742173F4_8580_42ce_BF4E_4828036EB6A6_;
	}

private:
	static _FUNC_T m_apcFunc[__END__];
	_N_IF_T* m_pcIf;
	ULONG m_ulLenRcvBuff;
	const void* m_pRcvBuff;
	const void* m_pCurrRcvBuff;
#ifdef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
	ULONG m_ulLenSndBuff;
	void* m_pSndBuff;
#endif
};

template <class IF>
typename CMiddleToFront<IF>::_FUNC_T CMiddleToFront<IF>::m_apcFunc[__END__] = {
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	NULL,
	&CMiddleToFront<IF>::fnReturnWithAsync,
	&CMiddleToFront<IF>::fnReturnWithAsyncEcho,
};


#undef __SYNC_CALL_7C82602D_4E46_47a6_BFDD_AD8D42FA3FCD__
}
